import React from 'react';


import classnames from 'classnames';
//component
import ReIcon from 'components/widgets/ReIcon';


import './index.less';


export default class view extends React.Component {
    static propTypes = {
        //name: React.PropTypes.string,
        type: React.PropTypes.string,
        text: React.PropTypes.string,
    };

    static defaultProps = {
        //name: 'component name'
    };


    constructor(props, context) {

        super(props, context);


        // init state;
        this.state = {};
    }

    componentWillMount() {
        this._isMounted = true;

    }

    componentDidMount() {

    }

    componentWillUnmount() {
        this._isMounted = false;
    }

    renderError() {
        return (
            <p className="error-text">
                <ReIcon icon="error_message"/>
                <span style={{marginLeft: '0.2rem'}}>{this.props.text}</span>
            </p>
        );
    }

    renderSuccess() {
        return (
            <p className="success-text">
                <ReIcon icon="prompt_correct"/>
                <span style={{marginLeft: '0.2rem'}}>{this.props.text}</span>
            </p>
        );
    }

    render() {

        const classNames = classnames({
            'orin-w-reinfotext-root': true,
            [this.props.className]: this.props.className ? true : false
        });

        return (
            <div className={classNames}>
                {this.props.text ? this.props.type === 'error' && this.renderError() : null}
                {this.props.type === 'success' && this.renderSuccess()}
            </div>
        );
    }
}
